import sys
import logging
from datetime import datetime
from stock_a.data.stock_a_info_fetcher import StockInfoFetcher

if __name__ == '__main__':
    argv_list = sys.argv
    if len(argv_list) < 2:
        logging.error('Please input the biz_date. For example: python sample_daily_executor.py 2025-01-26')
        sys.exit(-1)
    date = datetime.strptime(argv_list[1], '%Y-%m-%d').date()
    fetcher = StockInfoFetcher()
    # fetcher.clear_all_data()
    # fetcher.init_tables()
    fetcher.build_or_update_code_name()
    fetcher.build_or_update_hfq_factors()
    fetcher.build_or_update_day_k(date)
    fetcher.build_or_update_week_k(date)
    fetcher.build_or_update_month_k(date)
    fetcher.build_or_update_quarter_k(date)
    fetcher.build_or_update_year_k(date)
